Replication Files for "Heterogeneity and Aggregate Fluctuations"
by Minsu Chang, Xiaohong Chen, and Frank Schorfheide
For questions, please email Minsu Chang at minsu.chang@georgetown.edu

The scripts in this directory produce the results for Section 6:

/Data/ contains the empirical data, data sources are listed in Appendix E
/Figures/ contains the folders where figures generated by the code will be saved 
/Functions/ contains Julia functions that are used by the scripts
/Results/ contains the folders where main outputs of the Julia scripts will be saved 
/SpecFiles/ contains files with information on the fVAR specification and MCMC configurations.


Julia Scripts:

1. script_Density_Estimation.jl: estimates log spline densities by
MLE. Use fVARspec10tc.spec for cubic + linear basis

2. script_PredPercentiles_MLE.jl: computes percentiles based on
estimated log spline densities.

3. Graph_Percentiles_MLE.m: generates figure of fitted versus
empirical percentiles (Fig 8).

4. Graph_Densities.m: overlays estimated densities for different K
and histograms. Generates separate figures for each time period (Fig 8).

5. script_AggVAR_MDD.jl: loops over K, lambda, and number of lags to approximate the
MDD (for VAR with aggregate variables only)

6. script_AggVAR_Estimation.jl: estimates aggregate VAR

7. script_AggVAR_IRF.jl: creates IRFs to the three aggregate shocks identified by Cholesky factorization

8. script_MDD.jl: loops over K, lambda, and number of lags to approximate the
MDD (Tab 4).

9. script_SS_Estimation.jl: estimates state-space representation
conditional on K and lambda. 
SSspec1: K=10, lambda-hat
SSspec2: K=22, lambda-hat
SSspec3: K=10, lambda2,3=1

10. script_PredPercentiles_Alpha_Smoothed.jl: computes percentiles from
smoothed a/alpha states using posterior mean parameter estimates.

11. Graph_Alpha_Smoothed.m: overlays actual a-hat's and smoothed
a's (Fig A-7).

12. script_IRF.jl: creates IRFs to the three aggregate shocks
identified by Cholesky factorization

13. Graph_IRF_fVAR_AggV_AggSh.m: overlays two sets of IRFs of aggregate variables 
to aggregate shocks (Fig 9: functional VAR vs. aggregate VAR)

14. script_IRF_Transform.jl: compute IRFs for various
transformations of the original density responses. Use it for aggregate shock 

15. Graph_IRF_fVAR_AggSh.m: generates a variety of IRF plots for
aggregate shocks (Fig 10-11).

16. script_IRF_DistrSh.jl: creates IRFs to the distributional shock.

17. script_IRF_Transform.jl: compute IRFs for various
transformations of the original density responses. Use it for distributional shock now. 

18. Graph_IRF_fVAR_DistrSh.m: generates a variety of IRF plots for
distributional shocks (Fig 13 - Target Gini column)

19. script_AltVAR_MDD_Estimation: compute MDD for hyperparameter
selection. AltMDDspec1P = Pctl, AltMDDspec1G = Gini

20. script_AltVAR_Estimation: estimate alternative VAR conditional on
hyperparameters. AltVARspec1P = Pctl, AltVARspec1G = Gini

21. script_AltVAR_IRF: convert parameters into IRFs.

22. Graph_IRF_fVAR_v_AltVAR: overlay IRFs from functional model and AltVAR (Fig 12)

23. script_IRF_BCAnatomy.jl: creates IRFs to maximum-share-of-variance shock (business cycle anatomy). Agg2 = target GDP, Agg3 = target GDP, Distr1 = target distribution

24. script_IRF_transform_BCAnatomy.jl: compute IRFs for various
transformations of the original density responses. Use it for maximum-share-of-variance shock

25. Graph_IRF_fVAR_BCAnaotmy.m: generates a variety of IRF plots for maximum-share-of-variance shocks (Fig 13)

